//
//  UIButton+YYFramework.m
//  p2p
//
//  Created by mokai on 14-8-5.
//  Copyright (c) 2014年 cloudyoo. All rights reserved.
//

#import "UIButton+zframework.h"

@implementation UIButton (zframework)

-(id)initWithSystemTheme:(CGRect)frame{
    return [self initWithSystemTheme:frame title:nil];
}

-(id)initWithSystemTheme:(CGRect)frame title:(NSString *)title{
    return [self initWithSystemTheme:frame title:title target:nil action:nil];
}

-(id)initWithSystemTheme:(CGRect)frame title:(NSString *)title target:(id)target action:(SEL)action{
    if (self = [self initWithFrame:frame]) {
        [self setTitle:title forState:UIControlStateNormal];
        [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
        self.titleLabel.font =font(15);
        frame.origin.x = 0;
        frame.origin.y = 0;
        UIImage *image = [ImageUtils createImageWithColor:[UIColor themeColor] rect:frame];
        [self setBackgroundImage:image forState:UIControlStateNormal];
        self.layer.masksToBounds = YES;
        self.layer.cornerRadius = 3;
        return self;
    }
    return nil;
}

-(id)initWithFrame:(CGRect)frame title:(NSString *)title titleColor:(UIColor *)titleColor  target:(id)target action:(SEL)action{
    if (self = [self initWithFrame:frame]) {
        [self setTitle:title forState:UIControlStateNormal];
        [self setTitleColor:titleColor forState:UIControlStateNormal];
        [self addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
        self.titleLabel.font =font(15);
        self.layer.masksToBounds = YES;
        return self;
    }
    return nil;
}

//线条按钮
-(id)initWithFrame:(CGRect)frame title:(NSString *)title titleColor:(UIColor *)titleColor target:(id)target action:(SEL)action lineColor:(UIColor *)lineColor cornerRadius:(CGFloat)cornerRadius
{
    if (self = [self initWithFrame:frame]) {
        [self setTitle:title forState:UIControlStateNormal];
        [self setTitleColor:titleColor forState:UIControlStateNormal];
        [self addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
        self.titleLabel.font =font(16);
        self.layer.masksToBounds = YES;
        self.layer.borderColor = lineColor.CGColor;
        self.layer.borderWidth = 1;
        self.layer.cornerRadius = cornerRadius;
        return self;
    }
    return nil;

}

@end
